<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>课程列表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<meta http-equiv="content-type" content="text/html;charset=utf-8">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
	* {
		font-size: 11pt;
	}
	div {
		margin:20px;
		border: solid 2px gray;
		width: 150px;
		height: 150px;
		text-align: center;
	}
	li {
		margin: 10px;
	}
	
	#buy {
		background: url(<c:url value='/images/all.png'/>) no-repeat;
		display: inline-block;
		
		background-position: 0 -902px;
		margin-left: 30px;
		height: 36px;
		width: 146px;
	}
	#buy:HOVER {
		background: url(<c:url value='/images/all.png'/>) no-repeat;
		display: inline-block;
		
		background-position: 0 -938px;
		margin-left: 30px;
		height: 36px;
		width: 146px;
	}
</style>
  <script type="text/javascript" src="../../js/body.js"></script>
  <script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
  <script type="text/javascript" src="../../js/bootstrap.min.js"></script>
  <link href="../../css/bootstrap.min.css" rel="stylesheet">
  </head>
  
  <body>
  <script type="text/javascript">
  	$(document).ready(function(){
	 	$("#t").empty();
  		$.ajax({url:"${pageContext.request.contextPath}/syllabus/findBySid",
  		dataType:"json",
  		type:"post",
  		data:{term:getRealTerm()},
  		success:function(data, status){
  			for(var i = 0; i < data.data.syllabusItems.length; i++)
  			{
 				$("#t").append("<tr>");
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.cname+"</td>"); 
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.teacher.tname+"</td>"); 
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.period+"</td>"); 
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.credit+"</td>");
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.address+"</td>");
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.week+"</td>");
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.term+"</td>");
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.count+"</td>");
  				/* $("#t").append("<td><button type='button' class='btn btn-sm' onclick='loop(value)' value='"+data.data[i].cid+"'>详细</button></td>"); */
  				$("#t").append("</tr>"); 
  			}
  		}});
  	});
  	
  	function findBySid(value){
	 	$("#t").empty();
  		$.ajax({url:"${pageContext.request.contextPath}/syllabus/findBySid",
  		dataType:"json",
  		type:"post",
  		data:{term:value},
  		success:function(data, status){
  			for(var i = 0; i < data.data.syllabusItems.length; i++)
  			{
 				$("#t").append("<tr>");
   				$("#t").append("<td>"+data.data.syllabusItems[i].course.cname+"</td>"); 
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.teacher.tname+"</td>"); 
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.period+"</td>"); 
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.credit+"</td>");
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.address+"</td>");
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.week+"</td>");
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.term+"</td>");
  				$("#t").append("<td>"+data.data.syllabusItems[i].course.count+"</td>");
  				/* $("#t").append("<td><button type='button' class='btn btn-sm' onclick='loop(value)' value='"+data.data[i].cid+"'>详细</button></td>"); */
  				$("#t").append("</tr>"); 
  			}
  		}});
  	}
  </script>
<span>
	我的课程
	<select id = "term" onchange="findBySid(this.value)">
	</select>
</span>

		<table class="table table-bordered table-hover">
			<thead>
				<tr>
					<th>课程名称</th>
					<th>任课教师</th>
					<th>学时</th>
					<th>学分</th>
					<th>上课地点</th>
					<th>上课时间</th>
					<th>学期</th>
					<th>当前选课人数</th>
				</tr>
			</thead>
			<tbody id="t">
			
			</tbody>
		</table>

<%-- <c:choose>
	<c:when test="${empty syllabus.syllabusItems or fn:length(syllabus.syllabusItems) eq 0}">
		当前无课程
	</c:when>
	<c:otherwise>
<table border="1" width="100%" cellspacing="0" background="black">

	<tr>
		<th>课程名称</th>
		<th>任课教师</th>
		<th>学时</th>
		<th>学分</th>
		<th>上课地点</th>
		<th>上课时间</th>
		<th>学期</th>
		<th>当前选课人数</th>
	</tr>
<c:forEach items="${syllabus.syllabusItems }" var="syllabusItem">
	<tr>
		<td>${syllabusItem.course.cname }</td>
		<td>${syllabusItem.course.teacher.tname }</td>
		<td>${syllabusItem.course.period }</td>
		<td>${syllabusItem.course.credit }</td>
		<td>${syllabusItem.course.address }</td>
		<td>${syllabusItem.course.week }</td>
		<td>${syllabusItem.course.term }</td>
		<td>${syllabusItem.course.count }</td>

	</tr>
</c:forEach>



</table>
	</c:otherwise>
</c:choose> --%>
  </body>
</html>
